home *** CD-ROM | disk | FTP | other *** search
- NO_OUTPUT_BEGIN
- State code generation for Delphi from a state diagram
- 1. Create the state diagram
- 2. Generate - Generate State Code/Report
- 3. Save unit file as controls.pas
- 4. Compile controls.pas in Delphi
- NO_OUTPUT_END
-
- SCRIPT_NOREPEAT_HEADER_BEGIN
- unit Controls ;
-
- interface
-
- type
-
- States = ( [NO_RETURN STATE_LIST_NAME,DELETE_LAST_SYMBOL] ) ;
-
- Events = ( [NO_RETURN EVENT_LIST_NAME,DELETE_LAST_SYMBOL] ) ;
-
- Controller = class
-
- currentState : States;
-
- procedure Process ( anEvent : Events ) ;
-
- constructor DefaultInit;
-
- destructor Done; virtual;
-
- end;
-
- implementation
-
- {-----------------------------------------------------------------------------------------------}
-
- constructor Controller$.DefaultInit;
- begin
- currentState := STATE_INITIAL_NAME ;
- end;
-
- {-----------------------------------------------------------------------------------------------}
- {Update as required.}
- destructor Controller$.Done;
- begin
- end;
-
- {-----------------------------------------------------------------------------------------------}
- { Process procedure }
- procedure Controller.Process ( anEvent : Events ) ;
- begin
- case currentState of
-
- SCRIPT_NOREPEAT_HEADER_END
-
- STATE_NAME:
- begin
- [
- if ( anEvent = TRANSITION_EVENT ) And ( TRANSITION_CONDITION ) then
- begin
- currentState := TRANSITION_NEXT_STATE ;
- TRANSITION_ACTION
- end;
- ]
- end;
-
- SCRIPT_NOREPEAT_FOOTER_BEGIN
- else
- currentState := STATE_TERMINAL_NAME;
- end;
- end;
-
-
- end.
- SCRIPT_NOREPEAT_FOOTER_END
-